package com.rx.sample.service.impl;

import com.rx.sample.model.Address;
import com.rx.sample.service.AddressService;
import org.apache.dubbo.config.annotation.Service;

import java.util.HashMap;
import java.util.Map;

@Service(protocol = "dubbo")
public class AddressServiceImpl implements AddressService {

    private static final Map<Integer, Address> map = new HashMap() {{
        put(1, Address.builder().id(1).address("北京市昌平区").build());
        put(2, Address.builder().id(2).address("北京市海淀区").build());
        put(3, Address.builder().id(3).address("北京市朝阳区").build());
    }};

    @Override
    public Address getAddress(Integer id) {
        if (id != null && map.containsKey(id)) {
            return map.get(id);
        }
        return Address.builder().build();
    }

}
